CC=/usr/local/arm-apple-darwin/bin/gcc
LD=$(CC)
LDFLAGS=-Wl,-syslibroot,/usr/local/arm-apple-darwin/heavenly -lobjc -ObjC -framework CoreFoundation -framework Foundation -framework UIKit
CFLAGS = -Wall
UI_OBJS = source/ui/main.o source/ui/STSpeaka.o source/ui/STSpeakaPreferences.o source/ui/ServiceTableCell.o source/ui/SpeakaServiceTableCell.o
DAEMON_OBJS= source/daemon/ispeakad.o

all:	package

iSpeaka: $(UI_OBJS)
	$(LD) $(LDFLAGS) -o $@ $^

ispeakad: $(DAEMON_OBJS)
	$(LD) $(LDFLAGS) -o $@ $^

%.o:	%.m
	$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@

package: iSpeaka ispeakad
	rm -fr build
	mkdir -p build/iSpeaka.app
	cp -r ./resources/package/*.* ./build/iSpeaka.app
	cp ./resources/launchd/Library-LaunchDaemons/*.plist ./build/iSpeaka.app	
	mv iSpeaka ./build/iSpeaka.app
	mv ispeakad ./build/iSpeaka.app

clean:	
	rm -f source/ui/*.o iSpeaka
	rm -rf ./build